let express = require('express')
let path = require('path')
let imgapp = express()
// const mysql = require('mysql')
const cors = require('cors') //解决跨域请求问题
imgapp.use(cors())
imgapp.use(express.json());
imgapp.use(express.urlencoded({ extended: true }))

imgapp.all("*", function (req, res, next) { //配置预检请求
    // console.log(req.method);
   
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Content-type");
    res.header("Access-Control-Allow-Methods", "POST,GET,OPTIONS");
    res.header("Access-Control-Max-Age", 1728000); //预请求缓存20天
    next();
   
  });
// let port = 3100
imgapp.use(express.static(path.join(__dirname)))

    imgapp.listen(8888, () => {
        console.log('express server listening...')
    })
